package lesson3.slides.io;

import java.io.*;

public class DataOutput_Input {

    public static void main(String[] args) {
        try {
            DataOutputStream out = new DataOutputStream(
                    new BufferedOutputStream(
                    new FileOutputStream("Data.tmp")));
            out.writeDouble(839.829);
            System.out.println("Wrote " + 839.829);
            out.writeInt(-1872);
            System.out.println("Wrote " + (-1872));
            out.close();
            DataInputStream in = new DataInputStream(
                    new BufferedInputStream(
                    new FileInputStream("Data.tmp")));
            double d = in.readDouble();
            System.out.println("Read " + d);
            int i = in.readInt();
            System.out.println("Read " + i);
            in.close();
        } catch (Exception e) {
            //bad practice.. But quick and dirty
            throw new RuntimeException(e);
        }
    }
}
